// packageK/eGou/tackGoods/tackGoods.js
var d = getApp()
Page({
  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    deliver_id: "",
    name: "",
    show: false,
    num: "",
    goodsId: ""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      goodsId: options.id
    })
    this.getList()
  },
  onChange(event) {
    let data = event.currentTarget.dataset.item

    this.setData({
      deliver_id: data.id,
      name: data.deliver_name,
      num: "",
      show: true
    });
  },
  getList: function () {
    var t = this,
      e = d.getNetAddresss("HuaYing.deliverList");
    d._getNetWork({
      url: e,
      success: function (e) {
        var a = e.data;
        if (a.result == 1) {
          t.setData({
            list: a.data
          })
        } else {
          wx.showToast({
            title: a.msg,
            icon: "none"
          })
        }
      },
      fail: function (t) {
        console.log(t);
      }
    });
  },
  onInput(e) {
    this.setData({
      num: e.detail.value
    })
  },
  onClose() {
    this.setData({
      show: false
    });
  },
  contrim() {
    var t = this,
      e = d.getNetAddresss("HuaYing.deliverApply");
    d._getNetWork({
      url: e,
      data:{
        deliver_id:t.data.deliver_id,
        goods_id:t.data.goodsId,
        num:t.data.num,
        uid:wx.getStorageSync('uid')
      },
      success: function (e) {
        var a = e.data;
        wx.showToast({
          title: a.msg,
          icon: "none"
        })
        if (a.result == 1) {
          t.setData({
            show:false
          })
        } 
      },
      fail: function (t) {
        console.log(t);
      }
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})